package com.atguigu.observer.demo3;

import java.util.Observable;
import java.util.Observer;

public class QQWebSite implements Observer {

	Observable observable;
	private float temperature;

	public QQWebSite(Observable observable) {
		this.observable = observable;
		this.observable.addObserver(this);
	}

	@Override
	public void update(Observable observable, Object WeatherObj) {
		if (observable instanceof WeatherData) {
			WeatherData wd = (WeatherData) observable;
			this.temperature = wd.getTemperature();
			display();
		}
	}

	public void display() {
		System.out.println("当前温度：" + this.temperature + "摄氏度");
	}
}